package NewSiteMisc;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


import utils.variable;
import utils.xMLGear;


public class templateCCMMaker
	{
	/************
	 * Variables
	 ************/
	
	
	/***************
	 * Constructeur
	 * @throws Exception 
	 ***************/
	public templateCCMMaker() throws Exception
		{
		//Variables
		
		/********
		 * Regex
		 ********/
		ccmRegex();
		/********/
		}
	
	private void ccmRegex() throws Exception
		{
		ArrayList<ArrayList<String>> arr;
		for(int i = 0; i<variable.getCcmParam().size(); i++)
			{
			arr = null;
			arr = new ArrayList<ArrayList<String>>();
			for(int j = 0; j<variable.getCcmParam().get(i).getArr().get(0).length; j++)
				{
				variable.getLogger().debug(variable.getCcmParam().get(i).getStr()+" : "+variable.getCcmParam().get(i).getArr().get(0)[j][1]);
				arr.add(variable.doRegex(variable.getCcmParam().get(i).getArr().get(0)[j][1]));
				}
			variable.getCcm().add(new VarCCM(variable.getCcmParam().get(i).getStr(), arr));
			}
		
		//Partitions
		processComplexValue(variable.getCcmParamPart(), variable.getCcmPart());
		
		//Calling Search Space
		processComplexValue(variable.getCcmParamCSS(), variable.getCcmCSS());
		
		//Translation Pattern
		processComplexValue(variable.getCcmParamTP(), variable.getCcmTP());
		
		// Called Party transformation Pattern
		processComplexValue(variable.getCcmParamCalledPTP(), variable.getCcmCalledPTP());
		
		//Calling Party transformation Pattern
		processComplexValue(variable.getCcmParamCallingPTP(), variable.getCcmCallingPTP());
		}
	
	public void processComplexValue(ArrayList<VarCCMParam> CcmParam, ArrayList<VarCCM> Ccm) throws Exception
		{
		ArrayList<ArrayList<String>> arr;
		for(int i = 0; i<CcmParam.get(0).getArr().size(); i++)
			{
			arr = null;
			arr = new ArrayList<ArrayList<String>>();
			for(int j = 0; j<CcmParam.get(0).getArr().get(i).length; j++)
				{
				System.out.println(CcmParam.get(0).getStr());
				System.out.println(CcmParam.get(0).getArr().get(i)[j][1]);
				arr.add(variable.doRegex(CcmParam.get(0).getArr().get(i)[j][1]));
				}
			Ccm.add(new VarCCM(CcmParam.get(0).getStr(), arr));
			}
		}
	
	/*2014*//*AR :)*/
	}
